<template>
  <router-view />
</template>

<script setup>
import { onMounted, ref } from "vue";
import { beforePluginKill } from "./views/main/js/setting";
import { randomDisplayText } from "./views/main/js/wiseSaying.js";
import { useRouter } from "vue-router";

const router = useRouter();

onMounted(() => {
  if (window.services.env === "main") {
    console.log("-----------主窗口---------------");

    window.utools.onPluginEnter((action) => {
      console.log("action", action);
      // 每次进入时随机显示一条语录
      randomDisplayText();
    });
    window.utools.onPluginOut((isKill) => {
      if (isKill) {
        // 插件完全退出
        beforePluginKill();
      }
    });
  } else if (window.services.env === "child1") {
    console.log("-----------子窗口---------------");
    router.push("/child");
  }
});
</script>
